<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("comctrls.inc.php");
use_unit("components4phpfull/jtxmldatasource.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtdivwindow.inc.php");
use_unit("components4phpfull/jtgroupbox.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Emp_Fuel_Create extends Page
{
   public $JSGetPrice = null;
   public $Label14 = null;
   public $JSMakeModel = null;
   public $cmbmodel = null;
   public $cmbmanufacturer = null;
   public $edYear = null;
   public $edPlate = null;
   public $Label13 = null;
   public $Label11 = null;
   public $Label10 = null;
   public $Label9 = null;
   public $edOdNow = null;
   public $lblcurr = null;
   public $GroupBox1 = null;
   public $lblNo = null;
   public $edNo = null;
   public $Label2 = null;
   public $cmbmode = null;
   public $lblprev = null;
   public $edMiles = null;
   public $lblMiles = null;
   public $edOdLast = null;
   public $lblDate = null;
   public $dpdate = null;
   public $hfError = null;
   public $JSValidate = null;
   public $lblli = null;
   public $lblpr = null;
   public $Label12 = null;
   public $btnShowType = null;
   public $btnShowFuel = null;
   public $lblType = null;
   public $cmbType = null;
   public $lblBrand = null;
   public $cmbBrand = null;
   public $btnShowAccount = null;
   public $edEngine = null;
   public $Label8 = null;
   public $edprice = null;
   public $Label7 = null;
   public $cmbAccount = null;
   public $Label4 = null;
   public $edTotcost = null;
   public $Label1 = null;
   public $edLiters = null;
   public $C = null;
   public $JTJavaScript18 = null;
   public $JTJavaScript17 = null;
   public $JTJavaScript16 = null;
   public $JTJavaScript15 = null;
   public $JTJavaScript14 = null;
   public $JTJavaScript13 = null;
   public $JTDivType = null;
   public $JTGroupBox6 = null;
   public $btnAddType = null;
   public $btnDelType = null;
   public $edType = null;
   public $listType = null;
   public $JTDivFuel = null;
   public $JTGroupBox5 = null;
   public $btnAddFuel = null;
   public $btnDelFuel = null;
   public $edFuel = null;
   public $listFuel = null;
   public $btnCancel = null;
   public $btnSubmit = null;
   public $edOctane = null;
   public $btnAddOctane = null;
   public $btnDelOctane = null;
   public $listOctane = null;
   public $JTDivOctane = null;
   public $JTGroupBox4 = null;
   public $btnAddCity = null;
   public $btnDelCity = null;
   public $edCity = null;
   public $listCity = null;
   public $JTDivCity = null;
   public $JTGroupBox3 = null;
   public $edBrand = null;
   public $btnAddBrand = null;
   public $listBrand = null;
   public $btnDelBrand = null;
   public $JTDivBrand = null;
   public $JTGroupBox1 = null;
   public $btnShowOctane = null;
   public $btnShowCity = null;
   public $JTJavaScript12 = null;
   public $JTJavaScript11 = null;
   public $JTJavaScript10 = null;
   public $JTJavaScript9 = null;
   public $JTJavaScript8 = null;
   public $JTJavaScript7 = null;
   public $JTJavaScript6 = null;
   public $JTJavaScript5 = null;
   public $JTJavaScript4 = null;
   public $JTSiteTheme1 = null;
   public $JTJavaScript3 = null;
   public $JTJavaScript2 = null;
   public $JTJavaScript1 = null;
   public $compid = null;
   public $JTDivAccount = null;
   public $JTGroupBox2 = null;
   public $btnAddAccount = null;
   public $btnDelAccount = null;
   public $edAccount = null;
   public $listAccount = null;
   public $edDealer = null;
   public $imgBack = null;
   public $hiddenVeh = null;
   public $hiddenRoute = null;
   public $hiddenEmp = null;
   public $cmbCity = null;
   public $Label5 = null;
   public $Label6 = null;
   public $Label3 = null;
   public $cmboctane = null;
   public $Image1 = null;
   function cmbmanufacturerJSChange($sender, $params)
   {

?>
       makeModel();
       return false;
       <?php

   }

   function cmbmodeJSChange($sender, $params)
   {

?>
       var mode = document.getElementById('cmbmode').value;
       //alert(mode);
       if(mode=='Select' || mode=='Cash')
       {
       document.getElementById('lblNo_outer').style.visibility='hidden';
       document.getElementById('edNo_outer').style.visibility='hidden';
       }
       if(mode=='FleetCard' || mode=='Credit')
       {
       document.getElementById('lblNo_outer').style.visibility='visible';
       document.getElementById('edNo_outer').style.visibility='visible';
       }

       <?php

   }


   function edOdNowJSKeyUp($sender, $params)
   {

?>
       document.Emp_Fuel_Create.edMiles.value = (document.Emp_Fuel_Create.edOdNow.value) - (document.Emp_Fuel_Create.edOdLast.value);
       <?php

   }

   function edOdLastJSKeyUp($sender, $params)
   {

?>
       document.Emp_Fuel_Create.edMiles.value = (document.Emp_Fuel_Create.edOdNow.value) - (document.Emp_Fuel_Create.edOdLast.value);
       <?php

   }


   function edLitersJSBlur($sender, $params)
   {

?>
       //Add your javascript code here
       validateRequire('edLiters','lblli');
       <?php

   }

   function edpriceJSBlur($sender, $params)
   {

?>
       //Add your javascript code here
       validateRequire('edprice','lblpr');
       <?php

   }

   function Emp_Fuel_CreateJSLoad($sender, $params)
   {
      $this->clr_fuel();
?>
       var mode = document.getElementById('cmbmode').value;
       //alert(mode);
       if(mode=='Select' || mode=='Cash')
       {
       document.getElementById('lblNo_outer').style.visibility='hidden';
       document.getElementById('edNo_outer').style.visibility='hidden';
       }
       if(mode=='FleetCard' || mode=='Credit')
       {
       document.getElementById('lblNo_outer').style.visibility='visible';
       document.getElementById('edNo_outer').style.visibility='visible';
       }

       document.getElementById(edPlate_outer).style.textTranform='uppercase';

       <?php

   }



   function btnAddFuelJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       var addfuel = document.getElementById('edFuel').value;
       var compider = document.getElementById('compid').value;
       AjaxFuel2(addfuel,compider);
       document.getElementById('edFuel').value = "";
       <?php

   }

   function btnDelFuelJSClick($sender, $params)
   {

?>
       //Add your javascript code here
     var FuelIndex = document.getElementById('listFuel').selectedIndex;
     var FuelValue = document.getElementById('listFuel')[FuelIndex].value;
     var comp = document.getElementById('compid').value;
     AjaxFuel3(FuelValue,comp);
       <?php

   }

   function btnAddTypeJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       var addtype = document.getElementById('edType').value;
       var compider = document.getElementById('compid').value;
       AjaxType2(addtype,compider);
       document.getElementById('edType').value = "";
       <?php

   }

   function btnDelTypeJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       var TypeIndex = document.getElementById('listType').selectedIndex;
       var TypeValue = document.getElementById('listType')[TypeIndex].value;
       var comp = document.getElementById('compid').value;
       AjaxType3(TypeValue,comp);
       <?php

   }

   function cmbTypeJSChange($sender, $params)
   {
      //echo $this->cmbType->ajaxCall('price');
?>
      getPrice();

       <?php

   }

   function btnShowTypeJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       document.getElementById('JTDivType').Show();
       document.getElementById('edType').value = "";
       <?php

   }

   function btnShowFuelJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       document.getElementById('JTDivFuel').Show();
      document.getElementById('edFuel').value = "";
       <?php

   }

   function cmbBrandJSChange($sender, $params)
   {
      //echo $this->cmbBrand->ajaxCall('price');
?>
       getPrice();

       <?php

   }

   function btnDelOctaneJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       var OctaneIndex = document.getElementById('listOctane').selectedIndex;
       var OctaneValue = document.getElementById('listOctane')[OctaneIndex].value;
       var compider3 = document.getElementById('compid').value;
       AjaxOctane3(OctaneValue,compider3);
       <?php

   }

   function btnAddOctaneJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       var addoctane = document.getElementById('edOctane').value;
       var compider = document.getElementById('compid').value;
       AjaxOctane2(addoctane,compider);
       document.Route_Fuel.edOctane.value = " ";
       <?php

   }


   function btnShowOctaneJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       document.getElementById('JTDivOctane').Show();
       <?php

   }

   function btnDelCityJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       var CityIndex = document.getElementById('listCity').selectedIndex;
       var CityValue = document.getElementById('listCity')[CityIndex].value;
       var compider3 = document.getElementById('compid').value;
       AjaxCity3(CityValue,compider3);
       <?php

   }

   function btnAddCityJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       var addcity = document.getElementById('edCity').value;
       var compider = document.getElementById('compid').value;
       AjaxCity2(addcity,compider);
       document.Route_Fuel.edCity.value = " ";
       <?php

   }

   function btnShowCityJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       document.getElementById('JTDivCity').Show();
       <?php

   }

   function btnAddBrandJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       var addbrand = document.getElementById('edBrand').value;
       var compider = document.getElementById('compid').value;
       AjaxBrand2(addbrand,compider);
       document.getElementById('edBrand').value = " ";
       <?php

   }

   function btnDelBrandJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       var BrandIndex = document.getElementById('listBrand').selectedIndex;
       var BrandValue = document.getElementById('listBrand')[BrandIndex].value;
       var compider3 = document.getElementById('compid').value;
       AjaxBrand3(BrandValue,compider3);
       <?php

   }


   function btnShowBrandJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       document.getElementById('edBrand').value = "";
       document.getElementById('JTDivBrand').Show();
       <?php

   }



   function btnDelAccountJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       var AccountIndex = document.getElementById('listAccount').selectedIndex;
       var AccountValue = document.getElementById('listAccount')[AccountIndex].value;
       var compider3 = document.getElementById('compid').value;
       AjaxAccount3(AccountValue,compider3);
       <?php

   }

   function btnAddAccountJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       var addaccount = document.getElementById('edAccount').value;
       var compider = document.getElementById('compid').value;
       AjaxAccount2(addaccount,compider);
      document.getElementById('edAccount').value = " ";
       <?php

   }


   function btnShowAccountJSClick($sender, $params)
   {

?>
       //Add your javascript code here
       document.getElementById('edAccount').value
       document.getElementById('JTDivAccount').Show();
       <?php

   }

   function imgBackJSMouseOut($sender, $params)
   {

?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back.png"
       <?php

   }

   function imgBackJSMouseOver($sender, $params)
   {

?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back2.png"
       <?php

   }

   function edpriceJSKeyUp($sender, $params)
   {

?>
       //Add your javascript code here
       document.Emp_Fuel_Create.edTotcost.value = (document.Emp_Fuel_Create.edLiters.value) * (document.Emp_Fuel_Create.edprice.value);
       <?php

   }

   function edLitersJSKeyUp($sender, $params)
   {

?>
       //Add your javascript code here
       document.Emp_Fuel_Create.edTotcost.value = (document.Emp_Fuel_Create.edLiters.value) * (document.Emp_Fuel_Create.edprice.value);
       <?php

   }

   function btnCancelClick($sender, $params)
   {
      redirect('route_emp_fuel_list.php?emp=' . $this->hiddenEmp->getValue());


   }


   function price()
   {
      $type_id = $this->cmbType->getItemIndex();
      $brand = $this->cmbBrand->getItemIndex();

      $query_type = "SELECT value FROM lookup_fuel_tbl WHERE id='" . $type_id . "'";
      $result_type = mysql_query($query_type)or die("SELECT FUEL TYPE " . mysql_error());
      $row_type = mysql_fetch_array($result_type);
      $type = $row_type['value'];

      $query_price = "SELECT price FROM fuel_price_tbl WHERE company_id='" . $_SESSION['company_id'] . "' AND brand='" . $brand . "' AND type='" . $type . "'";
      $result_price = mysql_query($query_price)or die("SELECT PRICE " . mysql_error());
      $row_price = mysql_fetch_array($result_price);

      $price = $row_price['price'];
      $this->edprice->Text = $price;

      $total = $this->edprice->Text * $this->edLiters->Text;
      $this->edTotcost->setText($total);
   }


   function clr_fuel()
   {
      $this->edLiters->Text = '';
      $this->edTotcost->Text = '';
      $this->edprice->Text = '';
      $this->edDealer->Text = '';

      $this->cmbAccount->Clear();
      $this->cmbAccount->AddItem('--Select--', null , null);
      $this->cmbAccount->setItemIndex('--Select--', null , null);
      $result_account = mysql_query("select value from lookup_expense_tbl where company_id = '" . $_SESSION['company_id'] . "' AND category='accounts'");
      while($row_account = mysql_fetch_array($result_account))
      {
         $this->cmbAccount->AddItem($row_account['value'], null , $row_account['value']);
      }

      $this->cmbType->Clear();
      $this->cmbType->AddItem('--Select--', null , null);
      $this->cmbType->setItemIndex('--Select--', null , null);
      $this->cmbType->ItemIndex = $ftype;
      $result_fuel = mysql_query("select value,id from lookup_fuel_tbl where company_id = '" . $_SESSION['company_id'] . "' AND category='octane/Types'");

      while($row_fuel = mysql_fetch_array($result_fuel))
      {
         $this->cmbType->AddItem($row_fuel['value'], null , $row_fuel['id']);
      }

      $this->cmbBrand->Clear();
      $this->cmbBrand->AddItem('--Select--', null , null);
      $this->cmbBrand->setItemIndex('--Select--', null , null);
      $result_brand = mysql_query("select value from lookup_fuel_tbl where company_id = '" . $_SESSION['company_id'] . "' AND category='brands'");

      while($row_brand = mysql_fetch_array($result_brand))
      {
         $this->cmbBrand->AddItem($row_brand['value'], null , $row_brand['value']);
      }

   }

   function validateRequired($value, $lbl)
   {
      if($value == '' || $value == null)
      {
         $this->$lbl->Caption = '&darr; This field is required &darr;';
         $this->hfError->setValue('1');
      }
   }

   function fillCmbManufacturer()
   {
      $this->cmbmanufacturer->Clear();
      $this->cmbmanufacturer->AddItem('--Select--', null , '--Select--');
      $result_mnfr = mysql_query("select * from lookup_vehicle_tbl where company_id='" . $_SESSION['company_id'] . "' and category='manufacturer' order by value asc");

      while($row_mnfr = mysql_fetch_array($result_mnfr))
      {
         $this->cmbmanufacturer->AddItem($row_mnfr['value'], null , $row_mnfr['id']);
      }
   }


   function Emp_Fuel_CreateCreate($sender, $params)
   {
      $this->fillCmbManufacturer();

      $this->hfError->setValue('0');
      $this->lblpr->Caption = '';
      $this->lblli->Caption = '';
      $this->edOdLast->Text = '';
      $this->edOdNow->Text = '';
      $this->edMiles->Text = '';

      $this->compid->Value = $_SESSION['company_id'];

      if($_SESSION['isAdmin'] != 1)
      {
         $this->btnSubmit->setVisible(false);
         $this->btnCancel->setVisible(false);
      }


      $emp = $_GET['emp'];
      $route = $_GET['route'];
      $veh = $_GET['veh'];
      $this->hiddenEmp->setValue($emp);
      $this->hiddenRoute->setValue($route);
      $this->hiddenVeh->setValue($veh);

      $result_veh = mysql_query("select * from vehicle_tbl where vehicle_id='" . $this->hiddenEmp->getValue() . "'")or die(mysql_error);
      $row_veh = mysql_fetch_array($result_veh);

      $this->edEngine->Text = $row_veh['engine_model'];

      $track = $row_veh['track_by'];

      /*if($track=='hours')
      {
      $this->edOdLast->Text = $row_veh['curr_hours'];
      $this->lblprev->Caption = 'Previous Hours:';
      $this->lblcurr->Caption = 'Current Hours:';
      }

      if($track=='distance')
      {
      $this->edOdLast->Text = $row_veh['curr_tracking_value'];
      $this->lblprev->Caption = 'Previous Odometer:';
      $this->lblcurr->Caption = 'Current Odometer:';
      }*/


      $this->imgBack->setLink('route_emp_fuel_list.php?emp=' . $this->hiddenEmp->getValue());


      $result_date = mysql_query("SELECT start_date FROM route_tbl WHERE route_id='" . $this->hiddenRoute->getValue() . "'")
      or die("GET DATE " . mysql_error());
      $row_date = mysql_fetch_array($result_date);
      $this->dpdate->setText($row_date['start_date']);
      /*
      $result_fuel = mysql_query("select * from rou_fuel_tbl where emp_id='".$this->hiddenEmp->getValue()."' and route_id='".$this->hiddenRoute->getValue()."'");
      $row_fuel = mysql_fetch_array($result_fuel);

      $this->edLiters->Text=$row_fuel['gallons'];
      $this->edTotcost->Text=$row_fuel['tot_cost'];
      $this->edprice->Text=$row_fuel['price'];
      $this->edEngine->Text=$row_fuel['engine'];
      $this->edDealer->Text=$row_fuel['dealer'];
      */
      $this->edLiters->Text = '';
      $this->edTotcost->Text = '';
      $this->edprice->Text = '';
      //$this->edEngine->Text='';
      $this->edDealer->Text = '';
      $this->edPlate->Text = '';
      $this->edYear->Text = '';

      $this->cmbOctane->Clear();
      $result_octane = mysql_query("select value from lookup_fuel_tbl where company_id = '" . $_SESSION['company_id'] . "' AND category='octane/Types'");

      while($row_octane = mysql_fetch_array($result_octane))
      {
         $this->cmbOctane->AddItem($row_octane['value'], null , $row_octane['value']);
      }

      //list octane
      $this->edOctane->Text = "";
      $result_o = mysql_query("select value from lookup_fuel_tbl where company_id = '" . $_SESSION['company_id'] . "' AND category='octane/Types'");

      while($row_o = mysql_fetch_array($result_o))
      {
         $this->listOctane->AddItem($row_o['value'], null , $row_o['value']);
      }

      $this->cmbAccount->Clear();
      $this->cmbAccount->AddItem('--Select--', null , null);
      $this->cmbType->setItemIndex('--Select--');
      $result_account = mysql_query("select value from lookup_expense_tbl where company_id = '" . $_SESSION['company_id'] . "' AND category='accounts'");
      while($row_account = mysql_fetch_array($result_account))
      {
         $this->cmbAccount->AddItem($row_account['value'], null , $row_account['value']);
      }


      //list account
      $this->listAccount->Clear();
      $result_a = mysql_query("select value from lookup_expense_tbl where company_id = '" . $_SESSION['company_id'] . "' AND category='accounts'");
      while($row_a = mysql_fetch_array($result_a))
      {
         $this->listAccount->AddItem($row_a['value'], null , $row_a['value']);
      }


      $this->cmbType->Clear();
      $this->cmbType->AddItem('--Select--', null , null);
      $this->cmbType->setItemIndex('--Select--');
      //$this->cmbType->ItemIndex = $ftype;
      $result_fuel = mysql_query("select * from lookup_fuel_tbl where company_id = '" . $_SESSION['company_id'] . "' AND category='octane/Types' order by value asc");

      while($row_fuel = mysql_fetch_array($result_fuel))
      {
         $this->cmbType->AddItem($row_fuel['value'], null , $row_fuel['id']);
      }

      //list type
      $this->listType->Clear();
      $result_type = mysql_query("select * from lookup_fuel_tbl where company_id = '" . $_SESSION['company_id'] . "' AND category='octane/Types' order by value asc");

      while($row_type = mysql_fetch_array($result_type))
      {
         $this->listType->AddItem($row_type['value'], null , $row_type['id']);
      }


      $this->cmbCity->Clear();
      $result_loc = mysql_query("select value from lookup_fuel_tbl where company_id = '" . $_SESSION['company_id'] . "' AND category='state/province'");

      while($row_loc = mysql_fetch_array($result_loc))
      {
         $this->cmbCity->AddItem($row_loc['value'], null , $row_loc['value']);
      }

      //list city
      $this->edCity->Text = "";
      $result_c = mysql_query("select value from lookup_fuel_tbl where company_id = '" . $_SESSION['company_id'] . "' AND category='state/province'");

      while($row_c = mysql_fetch_array($result_c))
      {
         $this->listCity->AddItem($row_c['value'], null , $row_c['value']);
      }


      /*$this->cmbDealer->Clear();
      $result_dealer = mysql_query("select value from lookup_fuel_tbl where category='dealer names'");

      while($row_dealer = mysql_fetch_array($result_dealer))
      {
      $this->cmbDealer->AddItem($row_dealer['value'], null, $row_dealer['value']);
      }*/


      $this->cmbBrand->Clear();
      $this->cmbBrand->AddItem('--Select--', null , null);
      $this->cmbBrand->setItemIndex('--Select--');
      $result_brand = mysql_query("select value from lookup_fuel_tbl where company_id = '" . $_SESSION['company_id'] . "' AND category='brands' order by value asc");

      while($row_brand = mysql_fetch_array($result_brand))
      {
         $this->cmbBrand->AddItem($row_brand['value'], null , $row_brand['value']);
      }

      //list brand
      $result_b = mysql_query("select value from lookup_fuel_tbl where company_id = '" . $_SESSION['company_id'] . "' AND category='brands' order by value asc");

      while($row_b = mysql_fetch_array($result_b))
      {
         $this->listFuel->AddItem($row_b['value'], null , $row_b['value']);
      }

   }

   function btnSubmitClick($sender, $params)
   {
      $this->validateRequired($this->edprice->Text, 'lblpr');
      $this->validateRequired($this->edLiters->Text, 'lblli');
      $error = $this->hfError->getValue();
      if($error == '1' || $number != $key)
      {
         $this->hfError->setValue('0');
         return false;
      }
      else if($error == '0')
      {

         $result_route = mysql_query("SELECT * FROM route_tbl WHERE route_id='" . $this->hiddenRoute->getValue() . "'")
         or die("GET ROUTE " . mysql_error());
         $row_route = mysql_fetch_array($result_route);
         $dr_id = $row_route['dr1_id'];


         $result_driver = mysql_query("SELECT * FROM employee_tbl WHERE autoid='" . $dr_id . "'")
         or die("GET DRIVER " . mysql_error());
         $row_driver = mysql_fetch_array($result_driver);

         $fuel_t = $this->cmbType->getItemIndex();
         $result_ftype = mysql_query("select value from lookup_fuel_tbl where company_id = '" . $_SESSION['company_id'] . "' AND id='" . $fuel_t . "'");
         $row_ftype = mysql_fetch_array($result_ftype);
         $ftype2 = $row_ftype['value'];

         $result_veh = mysql_query("select * from vehicle_tbl where vehicle_id='" . $this->hiddenEmp->getValue() . "'")or die(mysql_error);
         $row_veh = mysql_fetch_array($result_veh);
         $track = $row_veh['track_by'];

         /*$result_fuel = mysql_query("select * from rou_fuel_tbl where route_id='" . $this->hiddenRoute->getValue(). "'");
         $fuel_count = mysql_num_rows($result_fuel);
         if($fuel_count == 0)
         {*/
         $result_fuel_id = mysql_query("SELECT MAX(autoid) as max FROM emp_fuel_tbl");
         $row_fuel_id = mysql_fetch_array($result_fuel_id);
         $fuel_id = $row_fuel_id['max'] + 1;

       $mnfr_id = $this->cmbmanufacturer->getItemIndex();
       $result_mnfr = mysql_query("SELECT value FROM lookup_vehicle_tbl WHERE company_id='".$_SESSION['company_id']."' and id='".$mnfr_id."'");
       $row_mnfr = mysql_fetch_array($result_mnfr);

       $result = mysql_query("INSERT into emp_fuel_tbl (autoid,
       company_id,
       emp_id,
       date,
       payment_mode,
       card_num,
       track_by,
       plate,
       year,
       make,
       model,
       present_odometer,
       gallons,
       price,
       brand,
       account,
       type,
       tot_cost)

       VALUES ('" . $fuel_id . "',
       '" . $_SESSION['company_id'] . "',
       '" . $this->hiddenEmp->getValue() . "',
       '" . $this->dpdate->Text . "',
       '" . $this->cmbmode->getItemIndex() . "',
       '" . $this->edNo->Text . "',
       '" . $track . "',
       UPPER('" . $this->edPlate->Text . "'),
       '" . $this->edYear->Text . "',
       '" . $row_mnfr['value'] . "',
       '" . $this->cmbmodel->getItemIndex() . "',
       '" . $this->edOdNow->Text . "',
       '" . $this->edLiters->Text . "',
       '" . $this->edprice->Text . "',
       '" . $this->cmbBrand->getItemIndex() . "',
       '" . $this->cmbAccount->getItemIndex() . "',
       '" . $this->cmbType->getItemIndex() . "',
       '" . $this->edTotcost->Text . "')")or die('INSERT FUEL -' . mysql_error());

       echo"<script language=javascript>
       var answer = confirm('Click OK to add another record or CANCEL to go back to list');
       if(answer)
       {
       window.location = 'emp_rfuel_create.php?emp=".$this->hiddenEmp->getValue()."';
       }
       else
       {
       window.location = 'emp_rfuel_list.php?emp=".$this->hiddenEmp->getValue()."';
       }
       </script>";


       //redirect('route_emp_fuel_list.php?emp=' . $this->hiddenEmp->getValue());
      }
   }

}

global $application;

global $Emp_Fuel_Create;

//Creates the form
$Emp_Fuel_Create = new Emp_Fuel_Create($application);

//Read from resource file
$Emp_Fuel_Create->loadResource(__FILE__);

//Shows the form
$Emp_Fuel_Create->show();

?>